package com.orhon.smartcampus.modules.notice.mm;

import com.orhon.smartcampus.modules.notice.entity.Notice;
import com.orhon.smartcampus.modules.notice.gqlModel.GQLNotice;
import com.orhon.smartcampus.modules.base.mm.LangMapper;
import com.orhon.smartcampus.modules.user.mm.UserMapper;
import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper(
        uses = {
                LangMapper.class,
                UserMapper.class
        }
)
public interface NoticeMapper {

    NoticeMapper MAPPER = Mappers.getMapper(NoticeMapper.class);
    @Mappings({
            @Mapping(source = "id" , target = "id"),
            @Mapping(source = "noticeTitle" , target = "noticeTitle"),
            @Mapping(source = "noticeContent" , target = "noticeContent"),
            @Mapping(source = "sendingTime" , target = "sendingTime"),
            @Mapping(source = "createdBy" , target = "createdBy"),
            @Mapping(source = "updatedBy" , target = "updatedBy"),
            @Mapping(source = "createdAt" , target = "createdAt"),
            @Mapping(source = "updatedAt" , target = "updatedAt"),
            @Mapping(source = "deletedAt" , target = "deletedAt"),
            @Mapping(ignore = true, source = "baseSchoolsBySchoolId" , target = "school"),
            @Mapping(ignore = true, source = "schools" , target = "schools"),
    })
    GQLNotice toNotice(Notice entity);

    @InheritConfiguration(name = "toNotice")
    List<GQLNotice> toNoticeList(List<Notice> entities);
}
